/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.rpgmapper.tools;

import com.jme3.asset.AssetManager;
import com.jme3.input.InputManager;
import com.jme3.renderer.Camera;
import com.jme3.scene.Node;
import org.rpgmapper.camera.RTSCameraHandler;
import org.rpgmapper.manager.MapManager;
import org.rpgmapper.manager.SelectionManager;

/**
 *
 * @author Nehon
 */
public class AppContext {

    private static AppContext instance;
    private AssetManager assetManager;
    private InputManager inputManager;
    private MapManager mapManager;
    private SelectionManager selectionManager;
    private RTSCameraHandler rtsCam;
    private Node rootNode;
    private Node guiNode;

    private static AppContext getInstance() {
        if (instance == null) {
            instance = new AppContext();
        }
        return instance;
    }

    public static void init(AssetManager assetManager, InputManager inputManager, MapManager mapManager, Node rootNode, Node guiNode, Camera cam) {
        AppContext ctx = AppContext.getInstance();
        ctx.assetManager = assetManager;
        ctx.inputManager = inputManager;
        ctx.mapManager = mapManager;
        ctx.guiNode = guiNode;
        ctx.rootNode = rootNode;

        ctx.rtsCam = new RTSCameraHandler(cam, rootNode, assetManager);
        ctx.rtsCam.registerInputs(inputManager);

        ctx.selectionManager = new SelectionManager(cam, inputManager);
        ctx.selectionManager.addCharacterListener(mapManager);
    }

    public static Node getRootNode() {
        return getInstance().rootNode;
    }

    public static InputManager getInputManager() {
        return getInstance().inputManager;
    }

    public static RTSCameraHandler getRtsCam() {
        return getInstance().rtsCam;
    }

    public static AssetManager getAssetManager() {
        return getInstance().assetManager;
    }

    public static MapManager getMapManager() {
        return getInstance().mapManager;
    }

    public static Node getGuiNode() {
        return getInstance().guiNode;
    }

    public static SelectionManager getSelectionManager() {
        return getInstance().selectionManager;
    }
}
